package com.example.shop.fgo.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;

import com.example.shop.fgo.R;

import org.xutils.common.util.DensityUtil;

/**
 * Created by Administrator on 2017/3/2.
 */

public class DigLogout extends Dialog{
    private Button mBtDigOk;
    private Button mBtDigCancel;
    public OnLogoutClickListener mOnLogoutClickListener;

    public void setOnLogoutClickListener(OnLogoutClickListener onLogoutClickListener) {
        mOnLogoutClickListener = onLogoutClickListener;
    }

    public DigLogout(final Context context) {
        super(context);
        this.getWindow().setGravity(Gravity.BOTTOM);
        this.setContentView(R.layout.dig_logout);
        this.getWindow().setWindowAnimations(R.style.dig_logout);

        mBtDigOk = (Button) findViewById(R.id.bt_dig_ok);
        mBtDigCancel = (Button) findViewById(R.id.bt_dig_cancel);
        mBtDigCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                cancel();
            }
        });
        mBtDigOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               mOnLogoutClickListener.onLogout();
            }
        });

    }
    public void showDigLogout(){
        this.setTitle("确定要退出登录吗？");
        this.show();
        this.getWindow().setLayout(DensityUtil.getScreenWidth(),DensityUtil.dip2px(200));
        //不设置背景的话，会造成底部弹窗宽度不是充满屏幕的。
        this.getWindow().setBackgroundDrawableResource(R.drawable.bottom_delog_btn_normal);
    }

    @Override
    public void cancel() {
        super.cancel();
    }
    public interface OnLogoutClickListener{
        public void onLogout();
    }
}

